<template>
  <div class="common-search-form-component">
    <a-form :model="queryParams">
      <a-row :gutter="16">
        <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
          <a-form-item :label="$t('notification.title')">
            <a-input
              v-model:value="queryParams.title"
              :placeholder="$t('notification.searchPlaceholder')"
              allow-clear
              @keyup.enter="handleSearch"
            />
          </a-form-item>
        </a-col>
        
        <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
          <a-form-item :label="$t('notification.type')">
            <a-select
              v-model:value="queryParams.type"
              :placeholder="$t('notification.typePlaceholder')"
              allow-clear
              style="width: 100%"
            >
              <a-select-option :value="NotificationType.SYSTEM">{{ $t('notification.typeSystem') }}</a-select-option>
              <a-select-option :value="NotificationType.TASK">{{ $t('notification.typeTask') }}</a-select-option>
              <a-select-option :value="NotificationType.MESSAGE">{{ $t('notification.typeMessage') }}</a-select-option>
              <a-select-option :value="NotificationType.TODO">{{ $t('notification.typeTodo') }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
      
        <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
          <a-form-item :label="$t('notification.status')">
            <a-select
              v-model:value="queryParams.status"
              :placeholder="$t('notification.statusPlaceholder')"
              allow-clear
              style="width: 100%"
            >
              <a-select-option :value="NotificationStatus.UNREAD">{{ $t('notification.statusUnread') }}</a-select-option>
              <a-select-option :value="NotificationStatus.READ">{{ $t('notification.statusRead') }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>
        
        <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
          <a-form-item :label="$t('notification.level')">
            <a-select
              v-model:value="queryParams.level"
              :placeholder="$t('notification.levelPlaceholder')"
              allow-clear
              style="width: 100%"
            >
              <a-select-option :value="NotificationLevel.NORMAL">{{ $t('notification.levelNormal') }}</a-select-option>
              <a-select-option :value="NotificationLevel.IMPORTANT">{{ $t('notification.levelImportant') }}</a-select-option>
              <a-select-option :value="NotificationLevel.URGENT">{{ $t('notification.levelUrgent') }}</a-select-option>
            </a-select>
          </a-form-item>
        </a-col>

        <a-col :xs="24" :sm="12" :md="12" :lg="6" :xl="6">
          <a-form-item :label="$t('common.dateRange')">
            <a-range-picker
              :value="dateRange"
              @update:value="(val) => $emit('update:dateRange', val)"
              :placeholder="[$t('common.startDate'), $t('common.endDate')]"
              style="width: 100%"
            />
          </a-form-item>
        </a-col>
      </a-row>
    </a-form>
  </div>
</template>

<script setup lang="ts">
import { NotificationType, NotificationStatus, NotificationLevel } from '@/types/api/notification'
import type { NotificationQuery } from '@/types/api/notification'

defineOptions({
  name: 'SearchForm'
})

// Props定义
const props = withDefaults(defineProps<{
  queryParams: NotificationQuery
  dateRange?: [string, string] | undefined
}>(), {
  dateRange: undefined
})

// Emits定义
const emit = defineEmits(['search', 'reset', 'update:dateRange'])

// 搜索
const handleSearch = () => {
  emit('search')
}

// 重置
const handleReset = () => {
  emit('reset')
}
</script>

<style lang="scss" scoped>
@import '@/assets/styles/views/common.scss';
</style> 